#include "dtwentymodel.h"
#include "campaign.h"
#include "campaignitems.h"



DTwentyModel::DTwentyModel(QObject *parent) :
    ItemTreeModel(parent)
{
}

bool DTwentyModel::insertRows(int row, int count, const QModelIndex &parent)
{
    CampaignSuiteItem* suiteItem = itemFromIndex<CampaignSuiteItem*>(parent);
    if (!suiteItem)
    {
        return false;
    }

    int cols = columnCount(QModelIndex());

    beginInsertRows(parent, row, row+count);
    DataContainer* item = suiteItem->createChild();
    endInsertRows();

    if (item->fieldCount() > cols)
    {
        int first = cols;
        int last = item->fieldCount()-1;
        beginInsertColumns(QModelIndex(), first, last);
        endInsertColumns();
    }

    return item;
}


Qt::ItemFlags DTwentyModel::flags(const QModelIndex &index) const
{
    return QAbstractItemModel::flags(index) | Qt::ItemIsEditable;
}


